<?php

namespace IDock\Insurance\YAIC\Response;

use Exception;
use IDock\Http\Response;
use IDock\Printer\PolicyPaymentPrinter;

class PolicyPaymentResponse extends AllYAICResponse
{
    /**
     * @var PolicyPaymentPrinter $printer
     */
    public $printer = PolicyPaymentPrinter::class;

    public function printerInit(): Response
    {
        $this->printer = new PolicyPaymentPrinter();
        $this->printer->payUrl = $this->getBody()['responseBody']['signedAddress'] ?? '';
        if(empty($this->printer->payUrl)){
            throw new Exception("获取支付链接失败");
        }
        return $this;
    }
}
